import {defineStore} from "pinia";
import {ref, computed, reactive} from "vue";
import axios from "axios";
const API_URL = 'http://geek.itheima.net/v1_0/channels'
export const useStore = defineStore('main', () => {
  const state = reactive({
    count: ref(0)
  })
  const increment = () => {
    state.count++;
  };
  const decrement = () => {
    state.count--;
  };
  const doubleCount = computed(() => state.count * 2);
  const list = ref([])
  const getList = async () => {
    const res = await axios.get(API_URL)
    list.value = res.data.data.channels
  }
  return {
    state,
    increment,
    decrement,
    doubleCount,
    getList,
    list
  };
});
